package cn.wizzer.app.user.modules.models;


import cn.wizzer.framework.base.model.BaseModel;
import lombok.Data;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;

import java.io.Serializable;
import java.math.BigDecimal;

@Data
@Table("user_exchange")
@TableIndexes({@Index(name = "unique_no", fields = {"no"}, unique = true),
        @Index(name = "INDEX_CT_AT", fields = {"ctAt"}, unique = false)})
public class UserExchange extends BaseModel implements Serializable {

    @Column
    @Name
    @Comment("ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    @PrevInsert(uu32 = true)
    private String id;

    @Column
    @Comment("编号")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String no;

    @Column
    @Comment("用户ID")
    @ColDefine(type = ColType.VARCHAR, width = 32)
    private String userId;

    @Column
    @Comment("from金额")
    @ColDefine(type = ColType.FLOAT, width = 16, precision = 6)
    private BigDecimal fromAmount;

    @Column
    @Comment("to金额")
    @ColDefine(type = ColType.FLOAT, width = 16, precision = 6)
    private BigDecimal toAmount;

    @Comment("from币种ID")
    @Column
    @ColDefine(type = ColType.VARCHAR, width = 32,notNull = true)
    private String fromCurrencyId;

    @Comment("to币种ID")
    @Column
    @ColDefine(type = ColType.VARCHAR, width = 32,notNull = true)
    private String toCurrencyId;

    @Column
    @Comment("创建时间")
    @PrevInsert(els = @EL("$me.now()"))
    //Long不要用ColDefine定义,兼容oracle/mysql,支持2038年以后的时间戳
    private Long ctAt;

}
